package com.cskaoyan.javase.homework.day11.extend;

/**
 * @description: 扩展二
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo2 {
    public static void main(String[] args) {
        //Father f1 = new Son(1000); //0
        //System.out.println(f1.i); //10
        //System.out.println(((Son) f1).i); //1000

        //Father f2 = new Father(); //10
        //System.out.println(f2.i); //10

        Son s = new Son(1000); //0
        //System.out.println(s.i); //1000
    }
}

class Father {
    int i = 10;

    public Father() {
        System.out.println(getI());
    }

    public int getI() {
        return i;
    }
}

class Son extends Father {
    int i = 100;

    public Son(int i) {
        //super()
        this.i = i;
    }

    @Override
    public int getI() {
        return i;
    }
}